/*
 * Copyright (c) 2025, 大连理工大学 (Dalian University of Technology)
 *
 * Licensed under the Mulan PSL v2.
 * You can use this file according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of the License at
 *
 *     http://license.coscl.org.cn/MulanPSL2
 *
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. SEE THE MULAN PSL v2
 * FOR MORE DETAILS.
 */

#pragma once

#include "highfive/H5File.hpp"

#include "DBManager/IRepository/Input/Element/ICONM1Repository.h"
#include "DBManager/Repository/HDF5/Base/MpiRepositoryBase.h"

template <>
inline HighFive::DataType HighFive::create_datatype<SG::DataStructure::FEM::CONM1Data> ()
{
    HighFive::CompoundType compoundType = {
        { "EID", HighFive::create_datatype<SG::DataStructure::Common::I64> () },
        { "G", HighFive::create_datatype<SG::DataStructure::Common::I64> () },
        { "CID", HighFive::create_datatype<SG::DataStructure::Common::I64> () },
        { "M1", HighFive::create_datatype<SG::DataStructure::Common::Real> () },
        { "M2", HighFive::create_datatype<SG::DataStructure::Common::Real[2]> (), SG::DBManager::FIELD_SIZE, true },
        { "M3", HighFive::create_datatype<SG::DataStructure::Common::Real[3]> (), SG::DBManager::FIELD_SIZE, true },
        { "M4", HighFive::create_datatype<SG::DataStructure::Common::Real[4]> (), SG::DBManager::FIELD_SIZE, true },
        { "M5", HighFive::create_datatype<SG::DataStructure::Common::Real[5]> (), SG::DBManager::FIELD_SIZE, true },
        { "M6", HighFive::create_datatype<SG::DataStructure::Common::Real[6]> (), SG::DBManager::FIELD_SIZE, true },
        { "DOMAIN_ID", HighFive::create_datatype<SG::DataStructure::Common::I64> () },
    };
    return compoundType;
}
SG_DBMANAGER_HDF5_NAMESPACE_OPEN
class CONM1Repository : public ICONM1Repository, public MpiRepositoryBase<SG::DataStructure::FEM::CONM1Data>
{
  public:
    explicit CONM1Repository (HDF5Database& database);

    void InitialDatasetInfo () override;
};
SG_DBMANAGER_HDF5_NAMESPACE_CLOSE